
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0872
 * @Author : WangRuoyu 
 * @Date : 2023/5/23 17:31
 */

#include "iostream"

using namespace std;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", gcd(a, b));
    }

    return 0;
}